package org.ouwa.lms.client.service;

import org.ouwa.lms.client.model.Account;
import org.ouwa.lms.client.model.Authentication;
import org.ouwa.lms.client.support.exception.AppException;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("accountServices")
public interface RemoteAccountService extends RemoteService {
	/**
     * Creates a new account based on the given account.
     *
     * @param account The account to create.
     * @return The created account.
	 * @throws AccountException 
     */
    Account createAccount(Account account) throws AppException;
    
    /**
     * Logs in to the application based on the given authentication. On successful login the authentication will be
     * registered with this manager as the currently logged in user.
     *
     * @param authentication Holds the authentication information for the login.
     * @return The account logged in.
     * @throws AuthenticationException
     */
    Account login(Authentication authentication) throws AppException;
    
    /**
     * Logs out the currently authenticated user.
     */
    Authentication logout();
    
    /**
     * Returns the currently logged in authentication.
     *
     * @return The currently logged in authentication.
     */
    Authentication getCurrentAuthentication();
    
    /**
     * Removes an existing account based on the given account.
     * 
     * @param auth The account to be removed
     * @return The account's name
     * @throws AccountException
     */
    Account removeAccount(Authentication auth) throws AppException; 
    
    /**
     * Updates an existing account based on the given account.
     * 
     * @param account The account to be updated
     * @return The account's name
     * @throws AccountException
     */
    Account updateAccount(Account account) throws AppException;
    
    /**
     * Retrieves an account via the login email address.
     * 
     * @param email The given login email
     * @return The account retrieved
     * @throws AppException
     */
    Account getAccount(String email) throws AppException;
}
